﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Titan
{
    [DataContract]
    public class GroupPropertyExpressionCollection : IGroupPropertyExpressionCollection
    {


        [DataMember]
        private List<IGroupPropertyExpression> Items;
        public GroupPropertyExpressionCollection()
        {
            this.Items = new List<IGroupPropertyExpression>();
        }
        public GroupPropertyExpressionCollection(int capcity)
        {
            this.Items = new List<IGroupPropertyExpression>(capcity);
        }



        public void Add(IEnumerable<IGroupPropertyExpression> propertys)
        {
            Items.AddRange(propertys);
        }
        public void Add(IEnumerable<string> propertyNames)
        {
            foreach (string propertyName in propertyNames)
            {
                Items.Add(new GroupPropertyExpression(propertyName));
            }
        }
        public void Add(string propertyName)
        {
            Items.Add(new GroupPropertyExpression(propertyName));
        }

        #region List Interface
        public void Add(IGroupPropertyExpression item)
        {
            Items.Add(item);
        }
        public int IndexOf(IGroupPropertyExpression item)
        {
            return Items.IndexOf(item);
        }

        public void Insert(int index, IGroupPropertyExpression item)
        {
            Items.Insert(index, item);
        }

        public void RemoveAt(int index)
        {
            Items.RemoveAt(index);
        }

        public IGroupPropertyExpression this[int index]
        {
            get
            {
                return Items[index];
            }
            set
            {
                Items[index] = value;
            }
        }


        public void Clear()
        {
            Items.Clear();
        }

        public bool Contains(IGroupPropertyExpression item)
        {
            return Items.Contains(item);
        }

        public void CopyTo(IGroupPropertyExpression[] array, int arrayIndex)
        {
            Items.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return Items.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(IGroupPropertyExpression item)
        {
            return Items.Remove(item);
        }

        public IEnumerator<IGroupPropertyExpression> GetEnumerator()
        {
            return Items.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return Items.GetEnumerator();
        }
        #endregion

    }
}
